<?php
include './sql.php';

$conn=mysql_connect($mysql_server_name, $mysql_username,$mysql_password);
if(!$conn){
	die('connect failed!');
}
mysql_select_db($mysql_database, $conn);

mysql_query("SET NAMES utf8");

$result = mysql_query("SELECT nid,title,newstype,stime FROM news");
$json ="";
$data =array(); 
class User{
	public $nid;
	public $title;
	public $newstype;
	public $stime;
}

while ($row= mysql_fetch_array($result, MYSQL_ASSOC)){
	$user =new User();
	$user -> nid   = $row['nid'];
	$user -> title = $row["title"];
	$user -> newstype  = $row['newstype'];
	$user -> stime = $row['stime'];
	$data[]=$user;
}
$json = json_encode($data);
echo "{".'"newsinfo"'.":".$json."}";
mysql_close($conn);
?>